Compilers are computer programs that read applications or programs written in one language, i.e., a source language such as a high-level programming language, and convert the source language program into a second language, i.e., a target language. Additionally, compilers typically perform other functions, such as reporting errors and importing other files or libraries for use by the source language file. The product of a compilation is typically a machine code language that can be executed directly on a particular processor in a particular operating environment.
Generally, the compilation process involves two parts, a front end portion for doing analysis and a back end portion for performing synthesis. The front end analysis parses the source language file, checks for lexical, grammatical or syntactic problems, and creates an intermediate representation of the source language file. The synthesis step analyzes the intermediate representation of the source language file and generates the target language file from the intermediate representation. The back end synthesis primarily depends on a particular target machine and is relatively independent of the source language used in creating the source file. On the other hand, the front end analysis depends primarily on the specific source language used and is relatively independent of the target machine.
There are at least three types of high-level programming languages in use today. The primary types of languages may be classified as procedural languages, functional languages, and object oriented programming languages. Additionally, each specific programming language has an associated library of functions that may be used by a software developer using that language. For example, almost every programming language has an input/output library of functions to allow the user to read information from an input device, such as from a file or a keyboard, and to write information to an output device such as a file, a display or a printer. In order to use this library of functions, the source language file has an “include” or “import” statement that indicates to the compiler the name of the desired library file.
During compile time, a language-specific compiler reads the source language file, determines that a library declarations file is needed and continues by reading the library declarations file. Importantly, in order for the library declarations file to be handled by the compiler, the library declarations file must be written in the native language for that compiler, i.e., the same language as the source language file. For example, if a user writes a source level program in C++ and the program uses a library declarations file, such as “stdio.h”, then the library declarations file must be written in C++ so that the C++ compiler can read and understand the library declarations file. At runtime, the resulting executable program must execute along with a library program file that supplies the implementation of those items from the library declarations file actually used by the source language program written by the user.
One particular drawback associated with front end portions of compilers relates to the fact that only one type of source language file can be “consumed” by a particular front end. That is, compilers only compile files written in a particular source language and are not flexible in receiving other source language files. Moreover, the library declarations files that are imported by a compiler must also be written in the particular source language associated with a particular compiler. Unfortunately, different source languages provide benefits or advantages in performing some functions over other programming languages and many such benefits are associated with specific library functions. Since compilers for one language cannot use a library declarations file written in another language, library declarations files are often translated or rewritten into other source languages so that the library functions may be used by other source languages.
It is with respect to these considerations and others that the present invention has been made.